<!--# layout("/common/layout.html",{"jsBase":"/js/ncode/rightncode/"}){ -->

<form class="layui-form layui-form-pane" id="addForm"  lay-filter="editform">
    <input type="hidden" name="nCode" id="nCode">

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">名称</label>
				<div class="layui-input-inline">
                                <input type="text" name="codeName" id="codeName" autocomplete="off" maxlength="50" class="layui-input" >
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">对应权益角色</label>
				<div class="layui-input-inline">
                                <input type="text" name="roleId" id="roleId" autocomplete="off" maxlength="50" class="layui-input" >
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">2、体验卡，4、正式会员卡</label>
				<div class="layui-input-inline">
                                <layui:simpleDataSelect name="nType" value="${has(rightncode)?rightncode.nType:''}" data="${nTypeList}"
                                            attrId="id" attrName="name" laySearch="true" />
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">可用标记 1、可用，0、不可用</label>
				<div class="layui-input-inline">
                                <layui:simpleDataSelect name="nStatus" value="${has(rightncode)?rightncode.nStatus:''}" data="${nStatusList}"
                                            attrId="id" attrName="name" laySearch="true" />
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">是否已经激活 1、已经激活，0、未激活</label>
				<div class="layui-input-inline">
                                <layui:simpleDataSelect name="isActived" value="${has(rightncode)?rightncode.isActived:''}" data="${isActivedList}"
                                            attrId="id" attrName="name" laySearch="true" />
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">备注</label>
				<div class="layui-input-inline">
                                <input type="text" name="remark" id="remark" autocomplete="off" maxlength="50" class="layui-input" >
				</div>
            </div>
        </div>
    </div>
    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','rightncodeApi'], function(exports) {
    var form = layui.form;
    var rightncodeApi = layui.rightncodeApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(rightncodeJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                // $("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton-loading").loading();
                form.on('submit(form)', function(){
                    rightncodeApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(rightncodeJson))){  -->
    var formJson = ${rightncodeJson};
    form.val("editform",formJson);
    <!--# } -->
});
</script>
